package com.familyaccount.model;

import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

@Data
public class Transaction {
    private int id;
    private int createdBy;
    private int categoryId;
    private BigDecimal amount;
    private TransactionType type;
    private String description;
    private LocalDate transactionDate;
    private LocalDateTime createdAt;
    
    // Additional fields for display
    private String categoryName;
    private String userName;
    private String transactionDateStr;

    public enum TransactionType {
        INCOME,
        EXPENSE
    }

    public Transaction() {
    }

    public Transaction(int createdBy, int categoryId, BigDecimal amount, TransactionType type, 
                      String description, LocalDate transactionDate) {
        this.createdBy = createdBy;
        this.categoryId = categoryId;
        this.amount = amount;
        this.type = type;
        this.description = description;
        this.transactionDate = transactionDate;
    }

    public void setTransactionDate(LocalDate transactionDate) {
        this.transactionDate = transactionDate;
        if (transactionDate != null) {
            this.transactionDateStr = transactionDate.toString();
        } else {
            this.transactionDateStr = null;
        }
    }
} 